<template>
  <a-config-provider :locale="zhCN">
    <div class="app-right">
      <header_d></header_d>
      <div class="app-content">
        <router-view></router-view>
      </div> 
    </div>
  </a-config-provider>
</template>

<script>
import zhCN from 'ant-design-vue/es/locale/zh_CN';
import { defineAsyncComponent } from 'vue'
export default {
  name: 'App',
  data() {
    return {
      zhCN,
    }
  },
  components: {
    header_d: defineAsyncComponent(() => import('@/components/router/header.vue')), 
  },
  beforeCreate(){
    
  },
  


  mounted() {
    // this.$common_apis.Get_task_status();
    // this.$common_apis.Get_detail_status();
    // this.$common_apis.Get_task_fuzhis();
    // this.$common_apis.GetOrg();
    // this.$common_apis.GetRole(); 

    //CHECK USER LOING 

    this.check_login()
    
  },
  methods: {
    async check_login() {
      let UUMS_TOKEN_Storage=localStorage.getItem("UUMS_TOKEN");
      let uums_token="";
      if(UUMS_TOKEN_Storage){
        let uums_json=JSON.parse(UUMS_TOKEN_Storage)
        uums_token=uums_json?.token
      }
      if(uums_token){
        this.$store.state.token_object.uums_token = uums_token
        this.check_token();
      }
      else{
        this.open_login_url();
      }
    },
    open_login_url(){
      window.open(`https://nmgwxyy.cn/loginByPassword?redirectURLhome=%2Falatan%2Ftask%2Fmytask`)
    },
    async check_token(){
      let result=await this.$apis.check_token({
        uumstoken:this.$store.state.token_object.uums_token
      })
      if(result?.status===false){//如果不存在或无效则转入登陆页面
        this.open_login_url();
      }
      else if(result ||result?.result){ //如果token存在则保存自定义的token
        this.$store.state.user=result?.result
        let pic_result=await this.$apis.get_user_pic()
        if(pic_result){
          this.$store.state.userpic=`data:image/png;base64,${pic_result}`
        }
        let user_roles=await this.$apis.get_user_role()
        if(user_roles){
          this.$store.state.user_roles=user_roles
        }
      }
    },
  }
}
</script>
<style>
/* 设置滚动条的样式 */
::-webkit-scrollbar {
width:6px;
}
/* 滚动槽 */
::-webkit-scrollbar-track {
-webkit-box-shadow:inset006pxrgba(0,0,0,0.3);
border-radius:10px;
}
/* 滚动条滑块 */
::-webkit-scrollbar-thumb {
border-radius:10px;
background:rgba(0,0,0,0.1);
-webkit-box-shadow:inset006pxrgba(0,0,0,0.5);
}
::-webkit-scrollbar-thumb:window-inactive {
background:rgba(255,0,0,0.4);
}
</style>